#!/usr/bin/perl

# Created By Matt Wright
# Version 1.0
# Simple Password Creator
# Created on: 12/24/95 Christmas Eve! Last Modified On: 12/24/95

$num_args = @ARGV;
if (!($num_args == 2)) {
   print "Wrong Number of Arguments!\n";
   print "USAGE: passwd.pl [passwd_file] <username>\n\n";
   exit;
}
($file,$username) = @ARGV;

system 'stty', '-echo';
print "Adding password for $username to file $file\n";
print "New Password: "; chop($pass1 = <STDIN>);
print "\nRe-Type new password: "; chop($pass2 = <STDIN>);
while (!($pass1 eq $pass2)) {
   print "\nPasswords not the same.  Try Again.\n\n";
   print "\nNew Password: "; chop($pass1 = <STDIN>);   
   print "\nRe-Type new password: "; chop($pass2 = <STDIN>);
}
system 'stty', 'echo';
$passwd = crypt($pass1,MW);
open(FILE,">>$file") || die "Can't open file $file for writing: $!\n";
print FILE "$username: $passwd\n";
close(FILE);
print "\nUser $username Added to Password File $file\n";

# This program is a simple passwd making program.  It turns ordinary
# text into encrypted passwords like the passwd program in unix.

# This program does not have all the fancy features that the unix version 
# has however.
# This program can be used to create htaccess user databases.
# Just simply run it like:

# passwd.pl filename user
# where filename is the file you want the user and passwd to be stored in
# and  user is the username you want to add a passwd for.

# This script can also be used for WWWADMIN's passwd.txt file, if you forget
# the one you changed it to and can't change it from the web.

# Enjoy!
